package com.aaie.gru.util;

public enum ExceptionEnums {
    SYSTEM_ERROR("系统异常",500),

    LOGINUSER_IS_NULL("用户未登录",9000),

    DATA_INSERT_ERROR("数据插入失败",9001),

    DATA_DELETE_SUCCESS("删除成功",9002),

    DATA_DELETE_ERROR("删除失败",9003),

    DATA_UPDATE_ERROR("更新失败",9004),

    DATA_QUERY_ERROR("获取失败",9005),

    ADD_DATA_NO_PRI("新增的数据不能有主键id",1000),

    ADD_DATA_NEED_PRI("请传入ID",1004),

    ACCOUNT_NO_EMPTY("账号不能为空",1001),

    ACCOUNT_NO_DUPLICATE("账号不能重复",1002),

    PASSWORD_NO_EMPTY("密码不能为空",1003),

    NOTICE_TITLE_NO_EMPTY("公告标题不能为空",1004);

    private int ecode;

    private String emsg;

    ExceptionEnums(String emsg,int ecode) {
        this.ecode = ecode;
        this.emsg = emsg;
    }

    public int getEcode() {
        return ecode;
    }

    public String getEmsg() {
        return emsg;
    }

    public static ExceptionEnums statOf(int ecode) {
        for (ExceptionEnums state : values())
            if (state.getEcode() == ecode)
                return state;
        return null;
    }

}
